#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int main()
{
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int y = 0;
    int left = 1, right = 1;
    int ret = 0;
    while (right <= n)
    {
        y += a[right];
        while (y * 2 >= sum)
        {
            ret = max(ret, sum - y);
            y -= a[left++];
        }
        ret = max(ret, y);
        right++;
    }
    cout << ret;
    return 0;
}